library(tidyverse)
library(plotly)
library(p8105.datasets)
Load data
data(instacart)
Filter data
instacart =
instacart |>
select (department, aisle, order_hour_of_day, order_number, days_since_prior_order)
Plot bar chart
instacart |>
count(department) |>
filter(department != "missing") |>
mutate(department = fct_reorder(department, n)) |>
plot_ly (x = ~department, y = ~n, color = ~department,
type = "bar", colors = "viridis")
instacart |>
filter(department != "missing") |>
mutate(department = fct_reorder(department, order_hour_of_day)) |>
plot_ly(x = ~department, y = ~order_hour_of_day, color = ~department,
type = "box", colors = "viridis")